<?php
/**
 * (exporter)
 */
namespace App\Exporter\Products;

use App\Models\Product\ProductClassify;
use App\Models\Product\ProductSku;
use App\Models\Product\ProductSupplier;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
class SkuSupplierExporter extends ExcelExporter implements WithMapping
{
    protected $fileName = '产品供应商.csv';

    protected $headings = ['SKU','名称','组合','品类','供应商编码','供应商名称','最小起订量','采购单价','采购周期','是否默认'];

    public function map($model) : array
    {
        return [
            $model->sku->psku_code ?? '',
            $model->sku->psku_cn ?? '',
            ProductSku::$_isMix[$model->sku->is_mix ?? 0],
            ProductClassify::getTitleById($model->sku->classify_id ?? ''),
            $model->supplier->code ?? '',
            $model->supplier->name ?? '',
            $model->moq,
            $model->unit_price,
            $model->purchase_cycle,
            ProductSupplier::$_status[$model->status],
        ];
    }

}
